//
//  Guid.m
//  gongwei-ios
//
//  Created by xiaoxiachuanqi on 2020/1/22.
//  Copyright © 2020 gongwei-mac. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Guid.h"

@implementation Guid

+(Guid *)instance:(NSString *)_guid {
    Guid *guid = [[Guid alloc]init];
    [guid setGuid:_guid];
    return guid;
}
+(Guid *)makeNew {
    NSString *result;
    NSString *i;
    int j;
    result = @"";
    for (j = 0; j < 32; j++) {
        if (j == 8 || j == 12 || j == 16 || j == 20) {
            result = [result stringByAppendingString: @"_"];
        }
        i = [[NSNumber numberWithInt: floor(arc4random() * 16)] stringValue];
        result = [result stringByAppendingString: i];
    }
    return [Guid instance:result];
}

-(NSString *)toString
{
    return self._guid;
}

-(void)setGuid:(NSString *)_guid
{
    self._guid = _guid;
}

@end
